package 棋盘问题;

import java.util.Scanner;


public class Main {
    static int N = 10, n, k;
    static char[][] g = new char[N][N];
    static boolean[] col = new boolean[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (true) {
            n = in.nextInt();
            k = in.nextInt();
            if (n == -1 || k == -1) {
                return;
            }
            for (int i = 0; i < n; i++) {
                String s = in.next();
                for (int j = 0; j < n; j++) {
                    g[i][j] = s.charAt(j);
                }
            }
            System.out.println(dfs(0, 0));
        }
    }

    private static int dfs(int u, int s) {
        if (s == k) {
            return 1;
        }
        if (u == n) {
            return 0;
        }
        int ret = dfs(u + 1, s);
        for (int i = 0; i < n; i++) {
            if (g[u][i] == '#' && !col[i]) {
                col[i] = true;
                ret += dfs(u + 1, s + 1);
                col[i] = false;
            }
        }
        return ret;
    }
}
